<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改订单')" />
	<th:block th:include="include :: select2-css" />
	<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-order-edit" th:object="${order}">
            <input id="id" name="id" th:field="*{id}"  type="hidden">
            <h4 class="form-header h4">基本信息</h4>
			<div class="form-group">
				<label class="col-sm-2 control-label">订单编号：</label>
				<div class="col-sm-3">
					<input id="orderid" name="orderid" th:field="*{orderid}" class="form-control" type="text">
				</div>

				<label class="col-sm-2 control-label">订单类型：</label>
				<div class="col-sm-3">
					<!-- <input id="type" name="type" th:field="*{type}" class="form-control" type="text"> -->
					<select id="type" name="type" class="form-control m-b"
						th:field="*{type}">
						<option value="1001">快递取件</option>
						<option value="1002">快递寄件</option>
						<option value="1003">其他跑腿</option>
						<option value="1004">闪送订单</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">订单状态：</label>
				<div class="col-sm-3">
				<select id="orderShuxin" name="orderShuxin" class="form-control m-b" th:field="*{orderShuxin}">
									<option value="2001">待付款</option>
									<option value="2002">待接单</option>
									<option value="2003">待送达</option>
									<option value="2004">待确认</option>
									<option value="2005">已完成</option>
									<option value="2006">退款</option>
					<option value="2008">退款完成</option>
								</select>
				</div>

				<label class="col-sm-2 control-label">是否出库 ：</label>
				<div class="col-sm-3">
					<select id="chuku" name="chuku" class="form-control m-b"
						th:field="*{chuku}">
						<option value=1>已出库</option>
						<option value=0>未出库</option>
					</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">是否加单：</label>
				<div class="col-sm-3">
					<!-- <input id="ifJiadan" name="ifJiadan" th:field="*{ifJiadan}" class="form-control" type="text"> -->
					<select id="ifJiadan" name="ifJiadan" class="form-control m-b"
						th:field="*{ifJiadan}">
						<option value=1>加单</option>
						<option value=0>无加单</option>
					</select>
				</div>

				<label class="col-sm-2 control-label">加单ID：</label>
				<div class="col-sm-3">
					<input  name="jiadanbianhao" class="form-control" type="text">
				</div>


			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">详细需求：</label>
				<div class="col-sm-8">
					<textarea id="remarks" name="remarks" th:field="*{remarks}" class="form-control"></textarea>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">订单备注：</label>
				<div class="col-sm-8">
					<textarea id="orderRemark" name="orderRemark" th:field="*{orderRemark}" class="form-control"></textarea>
				</div>
			</div>

			<h4 class="form-header h4">送货信息</h4>
			<div class="form-group">
				<label class="col-sm-2 control-label">收货人：</label>
				<div class="col-sm-3">
					<input th:field="${userAddress.realname}" class="form-control"
						type="text" readonly="readonly">

				</div>
				<label class="col-sm-2 control-label">收货人电话：</label>
				<div class="col-sm-3">

					<input th:field="${userAddress.mobile}" class="form-control"
						type="text" readonly="readonly">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">骑手姓名：</label>
				<div class="col-sm-3">



					<input th:field="${riderUser.realname}" class="form-control"
						type="text" readonly="readonly">

				</div>

				<label class="col-sm-2 control-label">骑手电话：</label>
				<div class="col-sm-3">


					<input th:field="${riderUser.mobile}" class="form-control"
						type="text" readonly="readonly">

				</div>
			</div>

			<div class="form-group">

				<label class="col-sm-2 control-label">送货上门时间：</label>
				<div class="col-sm-3">
					<input id="peisongDate" name="peisongDate"
						th:field="*{peisongDate}" class="form-control" type="text" readonly="readonly">
				</div>


				<label class="col-sm-2 control-label">快件数量：</label>
				<div class="col-sm-3">
					<input id="number" name="number" th:field="*{number}"
						class="form-control" type="text" readonly="readonly">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">订单大小：</label>
				<div class="col-sm-3">
					<select id="size" name="size" class="form-control m-b"
						th:field="*{size}">
						<option value="">暂无</option>
					</select>
				</div>

				<label class="col-sm-2 control-label">送货上门：</label>
				<div class="col-sm-3">
					<select id="door" name="door" class="form-control m-b"
						th:field="*{door}">
						<option value=1>送货上门</option>
						<option value=0>不送上楼</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">收件地址：</label>
				<div class="col-sm-8">
					<input th:field="${userAddress.address}" class="form-control"
						type="text" readonly="readonly">
				</div>
			</div>







			<h4 class="form-header h4">费用信息</h4>
			<div class="form-group">
				<label class="col-sm-2 control-label">跑腿费：</label>
				<div class="col-sm-3">
					<input id="paotuifei" name="paotuifei" th:field="*{paotuifei}" class="form-control" type="text">
				</div>

				<label class="col-sm-2 control-label">小费：</label>
				<div class="col-sm-3">
					<input id="xiaofei" name="xiaofei" th:field="*{xiaofei}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">红包id：</label>
				<div class="col-sm-3">
					<input id="packetsId" name="packetsId" th:field="*{packetsId}" class="form-control" type="text">
				</div>

				<label class="col-sm-2 control-label">总金额：</label>
				<div class="col-sm-3">
					<input id="jine" name="jine" th:field="*{jine}" class="form-control" type="text">
				</div>
			</div>




			<h4 class="form-header h4">操作信息</h4>
			<div class="form-group">
				<label class="col-sm-2 control-label">创建时间：</label>
				<div class="col-sm-3 input-group date">
					<!-- <input id="creactDate" name="creactDate" th:field="*{creactDate}" class="form-control" type="text"> -->
					<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
					<input type="text" class="form-control" id="creactDate" name="creactDate" th:field="*{creactDate}" placeholder="yyyy-MM-dd HH:mm:ss">
				</div>
				<br/>
				<label class="col-sm-2 control-label">修改时间：</label>
				<div class="col-sm-3 input-group date">
					<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
					<input type="text" class="form-control" id="modifyDate" name="modifyDate" th:field="*{modifyDate}" placeholder="yyyy-MM-dd HH:mm:ss">
				</div>
			</div>

			<div id="returnArea" style="display: none;">
			<h4 class="form-header h4">退货信息</h4>

			<div class="form-group">
				<label class="col-sm-2 control-label">退款图片：</label>
				<div class="col-sm-8">
					<input id="returnImg" name="returnImg" th:field="*{returnImg}" class="form-control" type="hidden">
					<img id="returnPhoto" width="200px" height="200px">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">退货类型：</label>
				<div class="col-sm-3">
				<select id="returnType" name="returnType" class="form-control m-b"
						th:field="*{returnType}">
						<option value=""></option>
						<option value=1>退货退款</option>
						<option value=2>仅退款</option>
						<option value=3>仅退货</option>
				</select>

				</div>

				<label class="col-sm-2 control-label">审核结果：</label>
				<div class="col-sm-3">
				<select id="returnOperate" name="returnOperate" class="form-control m-b"
						th:field="*{returnOperate}">
						<option value=""></option>
						<option value=0>等待审核</option>
						<option value=1>同意退款</option>
						<option value=-1>不同意退款</option>
				</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">退款说明：</label>
				<div class="col-sm-3">
					<input id="returnExplain" name="returnExplain" th:field="*{returnExplain}" class="form-control" type="text">
				</div>

				<label class="col-sm-2 control-label">退款金额：</label>
				<div class="col-sm-3">
					<input id="returnMoney" name="returnMoney" th:field="*{returnMoney}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">退款时间：</label>
				<div class="col-sm-3">
					<input id="returnDate" name="returnDate" th:field="*{returnDate}" class="form-control" type="text">
				</div>

				<label class="col-sm-2 control-label">同意退款时间：</label>
				<div class="col-sm-3">
					<input id="passDate" name="passDate" th:field="*{passDate}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">退款原因：</label>
				<div class="col-sm-8">
					<input id="returnReason" name="returnReason" th:field="*{returnReason}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">审核备注：</label>
				<div class="col-sm-8">
					<input id="returnRemark" name="returnRemark" th:field="*{returnRemark}" class="form-control" type="text">
				</div>
			</div>



			</div>
		</form>


		<div class="container-div" id="orderGoods" style="display: none;">
		<div class="row">
			<div class="col-sm-12 search-collapse" style="display: none;">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li><input id="id" name="id" th:value="${orderId}" /></li>
							<li><a class="btn btn-primary btn-rounded btn-sm"
								onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm"
								onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<h4 class="form-header h4">订单商品</h4>
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
		</div>

    </div>
    <div th:include="include::footer"></div>
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
    var img = document.getElementById('returnPhoto');
	var fileinput = document.getElementById('returnImg');
	if (fileinput.value != '') {
		img.src = ctx + fileinput.value.substr(1);
	}
   		$("#creactDate").datetimepicker({
		    format: "yyyy-mm-dd hh:ii:ss",
		    autoclose: true
		});

   		$("#modifyDate").datetimepicker({
		    format: "yyyy-mm-dd hh:ii:ss",
		    autoclose: true
		});
		var prefix = ctx + "Order/order";

		var orderType=document.getElementById("type").value;
		var orderState=document.getElementById("orderShuxin").value;
        var ifAdd=document.getElementById("ifJiadan").value;


		if(orderType=='1004'||ifAdd=='1'){
			$('#orderGoods').css('display','block');
		};

		if(orderState=='2006'){
			$('#returnArea').css('display','block');
		}

		$("#form-order-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});

		 function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/edit", $('#form-order-edit').serialize());
	        }
	    }


		$(function() {
			var options = {
				url : prefix + "/goodsList",
				showSearch : false,
				showRefresh : false,
				showToggle : false,
				showColumns : false,
				showFooter: true,
				columns : [
				{
					field : 'remarks',
					title : '商品名称'
				}, {
						title: '图片',
					    formatter: function(value, row, index) {
					    	if($.common.isEmpty(row.xiaofei)){
					    		return $.table.imageView('http://demo.ruoyi.vip/ruoyi.png');
					    	} else {
					    		return $.table.imageView(row.xiaofei);
					    	}
					    }
				}, {
					field : 'jine',
					title : '单价'
				}, {
					field : 'chuku',
					title : '数量'
				}, {
					field : 'returnMoney',
					title : '总价',
					footerFormatter:function (value) {
				    	var sumBalance = 0;
				        for (var i in value) {
				        	sumBalance += parseFloat(value[i].returnMoney);
				        }
				        return "总计：" +"￥  "+ sumBalance + "元";
				    }
				} ]
			};

			$.table.init(options);
		});

		var jiadanId = '[[${jiadanOrder.orderid}]]';
		$("input[name=jiadanbianhao]").val(jiadanId);

	</script>
</body>
</html>
